import React from 'react'
//使用了 HTML5 history API 的高阶路由组件
// import { HashRouter, BrowserRouter, Link, Route, Redirect, Switch } from 'react-router-dom'
import { Route, BrowserRouter as Router } from 'react-router-dom'
// import { Route, Redirect, Switch } from 'react-router'
//于支持 HTML5 history API 的浏览器
// import createBrowserHistory from 'history/createBrowserHistory'
import createHistory from 'history/createBrowserHistory'


import Home from './pages/home/index'
import About from './pages/about/index'
import TopMenu from './pages/topmenu/index'

const history = createHistory();

export default class extends React.Component {
    render() {
        return (
            <Router history={history}>
                <Route render={({ location }) => {
                    return (
                        <div key={location.pathname}>
                            <TopMenu history={history} />
                            <Route location={location} path="/" exact component={Home} />
                            <Route location={location} path="/home" component={Home} />
                            <Route location={location} path="/about" component={About} />
                        </div>
                    )
                }}/>

            </Router>
        )
    }
}
